Program 1
#picaxe 14m			; set picaxe type

init:	setfreq m8		; double speed
	pause 1000		; allow 500ms to wake-up

main:	serout 5,t9600_8,("vpf 1.mp3",CR)	; send play 1.mp3
	pause 20000					; wait 10 seconds
	serout 5,t9600_8,("vst",CR)		; send stop
	pause 20000					; wait 10 seconds
	serout 5,t9600_8,("vpf 2.mp3",CR)	; send play 2.mp3
	pause 20000					; wait 10 seconds
	serout 5,t9600_8,("vst",CR)		; send stop
	pause 20000					; wait 10 seconds
	goto main


Program 2
#picaxe 14m			; set picaxe type

init:	setfreq m8		; double speed
	pause 1000		; allow 500ms to wake-up

main:	
	if pin0 = 1 then do_play		; play switch pushed
	if pin1 = 1 then do_stop		; stop switch pushed
	goto main

do_play:
	pause 10					; short debounce time
	if pin0 = 1 then do_play			; wait until switch released
	serout 5,t9600_8,("vpf 1.mp3",CR)	; send play 1.mp3
	goto main
	
do_stop:
	pause 10					; short debounce time
	if pin1 = 1 then do_stop			; wait until switch released
	serout 5,t9600_8,("vst",CR)		; send stop command
	goto main


Program 3
#picaxe 28x1	; set picaxe type

symbol first_byte = b0
symbol point = b1
symbol temp = b2
symbol loopcounter = b3

setup:
	; setup serial hardware 
	; at 9600 with background receive
	hsersetup b9600_4,%01
	
init:
	; Send Es until the unit responds correctly
	hserout 0,("E",CR)
	gosub	get_response
	if first_byte <> "E" then init

main:
	; check to see if a drive is actually inserted
	; response will start D for yes and N for no
	hserout 0,(CR)
	gosub	get_response
	if first_byte <> "D" then main 
	
	; play track 1.mp3
	; response will start D if ok, C if not
	hserout 0,("vpf 1.mp3",CR)
	gosub	get_response
	if first_byte <> "D" then main 
	
	' play ten seconds
	pause 10000

	' pause for 5 seconds
	hserout 0,("e") ; note no CR here
	pause 5000

	'play another ten seconds
	hserout 0,(CR) 
	gosub	get_response
	pause 10000

	' stop
	hserout 0,("vst",CR)
	gosub	get_response
	pause 5000
	
	goto main

	; Sub procedure to receive background bytes
get_response:
	pause 1000			; wait a while	
	point = 0			; reset local pointer
	
	get point,first_byte	; Save the first reply byte
	do
	   get point,temp		; get returned byte
	   sertxd (temp)		; transmit it
	   inc point		; increment pointer
	loop while temp <> CR	; if not CR loop
	
	hserptr = 0			; reset the background receive pointer 
	return


Program 4
logging:
	readadc 1, b20		; readadc value into variable b20

	; create a log file called 'log.txt
	hserout 0,("opw log.txt",CR)
	gosub	get_response

	bintoascii b20,b5,b6,b7 	; convert loopcounter byte to 3 ascii digits
							; and write 8 bytes loop_xyz
	hserout 0,("wrf ",$00,$00,$00,$09,CR,"value ",b5,b6,b7)
	gosub	get_response
	
	hserout 0,("clf log",CR)
	gosub	get_response
	
	pause 1000
	
	goto logging

